package com.windowes.weichang.controller.platform;

import com.windowes.weichang.access.AccessLimit;
import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.pojo.SysRole;
import com.windowes.weichang.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/7/28 下午8:27
 * @description:
 *
 **/
@RestController
@RequestMapping("role")
public class RoleController {

    @Autowired
    RoleService roleService;

    @AccessLimit(manageUser = true)
    @PostMapping("addOrUpdate")
    public ServerResponse addOrUpdate(@RequestBody SysRole sysRole) {
        return roleService.addOrUpdate(sysRole);
    }


    @AccessLimit(manageUser = true)
    @GetMapping("list")
    public ServerResponse list(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                               @RequestParam(value = "pageSize", defaultValue = "150") int pageSize) {
        return roleService.list(pageNo, pageSize);
    }
}
